package cn.tedu.admin.companyandjob.dao.persist.repository.impl;

import cn.tedu.admin.companyandjob.dao.persist.mapper.JobDetailMapper;
import cn.tedu.admin.companyandjob.dao.persist.repository.IJobRepository;
import cn.tedu.admin.companyandjob.pojo.entity.JobDetail;
import cn.tedu.admin.companyandjob.pojo.vo.JobListItemVO;
import cn.tedu.common.pojo.vo.PageData;
import cn.tedu.common.util.PageInfoToPageDataConverter;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class JobRepository implements IJobRepository {
    @Autowired
    JobDetailMapper jobDetailMapper;


    @Override
    public PageData<JobListItemVO> selectJobList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<JobListItemVO> list = jobDetailMapper.selectJobList();
        PageInfo<JobListItemVO> pageInfo = new PageInfo<>(list);
        return PageInfoToPageDataConverter.convert(pageInfo);
    }

    @Override
    public void updataJob(JobDetail jobDetail) {
        jobDetailMapper.updateById(jobDetail);
    }

    @Override
    public void deleteJob(Long jobId) {
        jobDetailMapper.deleteById(jobId);
    }
}
